﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MBSBLC;

namespace MBS
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        MBSBLC.BLC userblc;
        private bool result;

        public bool Result
        {
            get { return result; }
            set { result = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string userEmailID = (string)Session["USER_EMAILID"];
            USER_MAIL_ID.Value = userEmailID;
            Menu mp_Menu = (Menu)Page.Master.FindControl("NavigationMenu");
            if (string.IsNullOrEmpty(userEmailID))
            {

                Label1.Text = "Guest";
                mp_Menu.Items.RemoveAt(5);
                mp_Menu.Items.RemoveAt(4);
                mp_Menu.Items.RemoveAt(3);
                mp_Menu.Items.RemoveAt(2);
                mp_Menu.Items.RemoveAt(1);
               
              
            }else{
                BLC blc = new BLC();
                string role = blc.getUserRoleByEmailID(userEmailID);
                if (role==null || !role.Equals("Admin"))
                {
                    mp_Menu.Items.RemoveAt(5);
                    mp_Menu.Items.RemoveAt(4);
                    mp_Menu.Items.RemoveAt(3);
                    mp_Menu.Items.RemoveAt(2);
                    mp_Menu.Items.RemoveAt(1);
                }
                Label1.Text = userEmailID;
               
            }

            
            
           // NavigationMenu.Items[0].Enabled = false;
          //  Menu mp_Menu_1 = (Menu)Page.Master.FindControl("NavigationMenu");
           // mp_Menu_1.Items[0].Enabled = false;
         //   userblc = new MBSBLC.BLC();
        //    Result = userblc.authenticateUser(Convert.ToString(Request.Form["email"]), Convert.ToString(Request.Form["psw"]));
          //  if (Result)
         //   {
         //       Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "javascript:alert('Welcome')", true);
         //       NavigationMenu.Items[0].Enabled = false;
         //   }
            
        }
    }
}
